{{- if .Values.job.enabled -}}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "postgres-cluster.secretName" . }}
  labels:
    application: spilo
    spilo-cluster: {{ include "postgres-cluster.fullname" . }}
data:
  {{- if .Values.job.enabled }}
  {{- range $elm := (.Values.job.init.users) }}
    {{- $pass := default $elm.user (default (randAlphaNum 19 | nospace) $elm.password ) | b64enc | quote -}}
    {{- printf "%s: %s" $elm.user $pass | nindent 2}}
  {{- end }}
  {{- end }}
{{- end -}}